package com.example.springbootvue.Controller;

import com.example.springbootvue.Pojo.Student;
import com.example.springbootvue.Service.Getservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin   //支持跨域
@RestController
public class Getcontroller {
    @Autowired
    private Getservice getservice;

    @RequestMapping("/get")
    public Student get(Integer id) {
        return getservice.get(id);
    }

    @RequestMapping("/getall")
    public Student[] getAll() {
        return getservice.getAll();
    }

    @RequestMapping("/Insert")
    public String Insert(Student student) {
        return getservice.Insert(student);
    }

    @RequestMapping("/Delete")
    public String Delete(Integer id) {
        return getservice.Delete(id);
    }

    @GetMapping("/user/{id}")
    public Student getUserById(@PathVariable("id") Integer id) {
        return getservice.getUserById(id);
    }
}